#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    vector<string> findWords(vector<string> &words)
    {
        vector<string> ret;
        string rowIdx = "12210111011122000010020202";
        for (auto &e : words)
        {
            int cnt1, cnt2, cnt3;
            cnt1 = cnt2 = cnt3 = 0;
            for (int i = 0; i < e.size(); ++i)
            {
                char tmp = e[i];
                if (isupper(tmp))
                {
                    tmp = tolower(tmp);
                }
                int t = tmp - 'a';
                if (rowIdx[t] == '0')
                {
                    cnt1++;
                }
                else if (rowIdx[t] == '1')
                {
                    cnt2++;
                }
                else
                {
                    cnt3++;
                }
            }
            if (cnt1 == e.size() || cnt2 == e.size() || cnt3 == e.size())
            {
                ret.push_back(e);
            }
        }
        return ret;
    }
};